from selenium import webdriver
from time import sleep
from lxml import etree

url = "https://search.jd.com/Search?keyword=macbook%20pro&enc=utf-8&suggest=3.def.0.V19--38s0&wq=mac&pvid=1efda55044314b23ba76b2410c257de5/"
driver = webdriver.Chrome()
driver.get(url)
# js
js = "document.documentElement.scrollTop = 1000000"
driver.execute_script(js)

sleep(3)
source = driver.page_source
html = etree.HTML(source)
prices = html.xpath("//div[@class='gl-i-wrap']/div[@class='p-price']/strong/i/text()")
names = html.xpath("//div[@class='gl-i-wrap']/div[@class='p-name p-name-type-2']/a/em")
urls = html.xpath("//div[@class='gl-i-wrap']/div[@class='p-name p-name-type-2']/a/@href")
print(len(names))
for name, price, url in zip(names, prices, urls):
    print(f"{name.xpath('string(.)')}(https:{url})  :   ￥{price}")
driver.quit()
